﻿using MongoDB.Driver.GridFS;
using SimpleInjector;
using Sustainalytics.Download.Entities;
using Sustainalytics.MongoDB.Extensions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Sustainalytics.Download.GridFs
{
    public static class SimpleInjectorConfig
    {
        public static readonly string ClientPlatform = "ClientPlatform";

        public static Container Register(Dictionary<string, string> connectionStrings)
        {
            var container = new Container();

            container.RegisterCollections(connectionStrings);

            return container;
        }

        private static void RegisterCollections(this Container container, Dictionary<string, string> connectionStrings)
        {
            connectionStrings.TryGetValue(ClientPlatform, out string clientPlatform);

            container.Register(() => MongoFactory.GetDatabase(clientPlatform));
            container.Register(() => MongoFactory.GetCollectionFromClientPlatform<PIInputFile>());
        }
    }
}
